package com.threefish.modules.sys.entity.organize;

import com.threefish.common.entity.AbstractBaseEntity;
import org.nutz.dao.entity.annotation.*;
import org.nutz.plugins.validation.annotation.Validations;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @author 黄川 306955302@qq.com
 * @date: 2018/5/23
 * 描述此类：组织架构
 */
@Table("sys_department")
@Comment("部门机构")
public class Department extends AbstractBaseEntity implements Comparator<Department> {


    @Name
    @Prev(els = @EL("$me.uuid()"))
    @ColDefine(width = 32, notNull = true)
    @Comment("主键")
    @Column("id")
    private String id;

    @Column
    @ColDefine(width = 32, notNull = true)
    @Validations(required = true, errorMsg = "上级部门为必填项")
    private String pid;

    @Column
    @Comment("岗位编码(非必填)")
    private String code;

    @Column
    @Comment("部门名称")
    @Validations(required = true, strLen = {2, 50}, errorMsg = "部门名称不可为空，并且长度在2-50之间")
    private String name;

    @Column
    @Comment("编制数量")
    @ColDefine(width = 32)
    private int plaitNum;

    @Column
    @Comment("上级部门名称")
    @Validations(required = true, strLen = {2, 50}, errorMsg = "上级部门名称不可为空，并且长度在2-50之间")
    private String parentName;

    @Column
    @Comment("部门主管(可选)")
    @ColDefine(width = 500)
    @Default("")
    private String leader;

    @Column
    @Comment("部门主管(可选)-冗余字段")
    @ColDefine(width = 2000)
    @Default("")
    private String leaderDesc;

    @Column
    @Comment("部门助理(可选)")
    @ColDefine(width = 500)
    @Default("")
    private String assistant;

    @Column
    @Comment("部门助理(可选)-冗余字段")
    @ColDefine(width = 2000)
    @Default("")
    private String assistantDesc;

    @Column("parent_leader1")
    @Comment("上级主管领导(可选)")
    @ColDefine(width = 500)
    @Default("")
    private String parentLeader1;

    @Column
    @Comment("上级主管领导(可选)-冗余字段")
    @ColDefine(width = 2000)
    @Default("")
    private String parentLeader1Desc;

    @Column("parent_leader2")
    @Comment("上级分管领导(可选)")
    @ColDefine(width = 500)
    @Default("")
    private String parentLeader2;


    @Column
    @Comment("上级分管领导(可选)-冗余字段")
    @ColDefine(width = 2000)
    @Default("")
    private String parentLeader2Desc;

    @Column
    @Comment("部门电话")
    @ColDefine(width = 100)
    private String telphone;

    @Column
    @Comment("传真")
    @ColDefine(width = 100)
    private String fax;

    @Column
    @Comment("部门地址")
    @ColDefine(width = 200)
    private String address;

    @Column
    @Comment("部门职能")
    @ColDefine(width = 200)
    private String functions;

    @Column("short_no")
    @Comment("排序号")
    private int shortNo;

    /**
     * 一对多关系
     */
    @Many(field = "deptId")
    private List<DepartmentJob> departmentJobList;
    private List<Department> children = new ArrayList<>();
    /**
     * ztree支持
     **/
    private String iconSkin;
    private boolean chkDisabled = false;

    public List<DepartmentJob> getDepartmentJobList() {
        return departmentJobList;
    }

    public void setDepartmentJobList(List<DepartmentJob> departmentJobList) {
        this.departmentJobList = departmentJobList;
    }

    public int getPlaitNum() {
        return plaitNum;
    }

    public void setPlaitNum(int plaitNum) {
        this.plaitNum = plaitNum;
    }

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public String getLeaderDesc() {
        return leaderDesc;
    }

    public void setLeaderDesc(String leaderDesc) {
        this.leaderDesc = leaderDesc;
    }

    public String getAssistantDesc() {
        return assistantDesc;
    }

    public void setAssistantDesc(String assistantDesc) {
        this.assistantDesc = assistantDesc;
    }

    public String getParentLeader1Desc() {
        return parentLeader1Desc;
    }

    public void setParentLeader1Desc(String parentLeader1Desc) {
        this.parentLeader1Desc = parentLeader1Desc;
    }

    public String getParentLeader2Desc() {
        return parentLeader2Desc;
    }

    public void setParentLeader2Desc(String parentLeader2Desc) {
        this.parentLeader2Desc = parentLeader2Desc;
    }

    public String getTelphone() {
        return telphone;
    }

    public void setTelphone(String telphone) {
        this.telphone = telphone;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getFunctions() {
        return functions;
    }

    public void setFunctions(String functions) {
        this.functions = functions;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLeader() {
        return leader;
    }

    public void setLeader(String leader) {
        this.leader = leader;
    }

    public String getAssistant() {
        return assistant;
    }

    public void setAssistant(String assistant) {
        this.assistant = assistant;
    }

    public String getParentLeader1() {
        return parentLeader1;
    }

    public void setParentLeader1(String parentLeader1) {
        this.parentLeader1 = parentLeader1;
    }

    public String getParentLeader2() {
        return parentLeader2;
    }

    public void setParentLeader2(String parentLeader2) {
        this.parentLeader2 = parentLeader2;
    }

    public List<Department> getChildren() {
        return children;
    }

    public void setChildren(List<Department> children) {
        this.children = children;
    }

    public String getIconSkin() {
        return iconSkin;
    }

    public void setIconSkin(String iconSkin) {
        this.iconSkin = iconSkin;
    }

    public boolean isChkDisabled() {
        return chkDisabled;
    }

    public void setChkDisabled(boolean chkDisabled) {
        this.chkDisabled = chkDisabled;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }


    public int getShortNo() {
        return shortNo;
    }

    public void setShortNo(int shortNo) {
        this.shortNo = shortNo;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public int compare(Department o1, Department o2) {
        if (o1.getShortNo() > o2.getShortNo()) {
            return 0;
        } else {
            return -1;
        }
    }
}
